package com.ang.springboot.consumer.direct;

import com.alibaba.fastjson.JSON;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author ssang
 * @date 2022-04-09 23:11
 */
@Component
public class DirectConsumer {
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue("directQueue"),
            exchange = @Exchange(value = "directExchange",type = ExchangeTypes.DIRECT),
            key = {"directKey"}
    ))
    public void getMessage(Map msg){
        System.out.println("队列：directQueue；消费消息："+ JSON.toJSONString(msg));
    }
}
